package com.sagittarius.demo.handle;

import com.sagittarius.demo.common.Result;
import com.sagittarius.demo.exception.ExcelException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @ClassName ServerExceptionHandle.java
 * @Author 李瑞珂
 * @Version 1.0.0
 * @Description 服务异常处理类
 * @CreateTime 2022年04月30日 16:24:00
 */
@RestControllerAdvice
@Slf4j
public class ServerExceptionHandle {

    @ExceptionHandler(Exception.class)
    public Result<Exception> error(Exception e){
        e.printStackTrace();
        log.error(e.toString());
        return Result.fail(e);
    }

    @ExceptionHandler(ExcelException.class)
    public Result<ExcelException> error(ExcelException e){
        e.printStackTrace();
        log.error(e.toString());
        return Result.fail(e.getMessage());

    }

}
